﻿<UserControl x:Class="BillsManager.Views.DBBackupsView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:Caliburn="http://www.caliburnproject.org"
             xmlns:Controls="clr-namespace:BillsManager.Views.Controls"
             xmlns:Datatemplates="clr-namespace:BillsManager.Views.DataTemplates"
             xmlns:ViewModels="clr-namespace:BillsManager.ViewModels;assembly=BillsManager.ViewModels"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:Loc="clr-namespace:BillsManager.Localization;assembly=BillsManager.Localization"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             d:DataContext="{d:DesignInstance Type=ViewModels:DBBackupsViewModel,
                                              IsDesignTimeCreatable=True}"
             d:DesignHeight="300"
             d:DesignWidth="300"
             mc:Ignorable="d">

    <UserControl.Resources>
        <!--<ResourceDictionary Source="Dictionaries\Styles.xaml" />-->
        <ResourceDictionary Source="Themes\Themes.xaml" />
    </UserControl.Resources>

    <Controls:ListBoxEx EmptyMessage="{Loc:Translate NoBackupsAvailable}"
                        ItemsSource="{Binding BackupViewModels}"
                        SelectedItem="{Binding SelectedBackupViewModel}"
                        ShowEmptyMessage="True">

        <Controls:ListBoxEx.ItemTemplate>
            <DataTemplate>
                <Datatemplates:BackupDataTemplate />
            </DataTemplate>
        </Controls:ListBoxEx.ItemTemplate>

        <!--
            <Controls:ListBoxEx.ItemTemplate>
            <DataTemplate>
            <Grid>
            <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="{StaticResource View.MarginSize}" />
            <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <TextBlock Text="{Binding Path=CreationTime, StringFormat=\{0:F\}, Mode=OneTime}" />

            <TextBlock Grid.Row="2">
            <Run Text="Suppliers:" />
            <Run Text="{Binding Path=SuppliersCount, Mode=OneTime}" />
            </TextBlock>

            <TextBlock Grid.Row="4">
            <Run Text="Bills:" />
            <Run Text="{Binding Path=BillsCount, Mode=OneTime}" />
            </TextBlock>

            <TextBlock Grid.Row="6"
            Visibility="{Binding HasNoRollbacks, Converter={StaticResource BooleanToVisibilityConverter}}">
            <Run Text="Used " />
            <Run Text="{Binding Path=TimesUsedForRollback, Mode=OneTime}" />
            <Run Text=" times to restore" />
            </TextBlock>

            <Expander Grid.Row="6"
            Visibility="{Binding HasRollbacks, Converter={StaticResource BooleanToVisibilityConverter}}"
            BorderThickness="0"
            BorderBrush="{x:Null}"
            Background="{x:Null}"
            Focusable="False"
            Foreground="{Binding Foreground, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}">
            <Expander.Header>
            <TextBlock Grid.Column="1">
            <Run Text="Used " />
            <Run Text="{Binding Path=TimesUsedForRollback, Mode=OneTime}" />
            <Run Text=" times to restore" />
            </TextBlock>
            </Expander.Header>

            <ItemsControl ItemsSource="{Binding RollbackDates}">
            <ItemsControl.ItemTemplate>
            <DataTemplate>
            <TextBlock Text="{Binding Mode=OneWay, StringFormat=\{0:F\}}"
            Margin="24 8 0 0" />
            </DataTemplate>
            </ItemsControl.ItemTemplate>
            </ItemsControl>
            </Expander>

            </Grid>
            </DataTemplate>
            </Controls:ListBoxEx.ItemTemplate>
        -->

    </Controls:ListBoxEx>
</UserControl>